package com.intexh.quickandroid.module.mine;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.intexh.quickandroid.R;
import com.intexh.quickandroid.base.BaseActivity;
import com.intexh.quickandroid.net.Apis;
import com.intexh.quickandroid.net.NetworkManager;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FeedBackActivity extends BaseActivity {
    @BindView(R.id.back_iv)
    ImageView backIv;
    @BindView(R.id.title_tv)
    TextView titleTv;
    @BindView(R.id.content_et)
    EditText contentEt;
    @BindView(R.id.submit_btn)
    Button submitBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feed_back);
        ButterKnife.bind(this);
        titleTv.setText("意见反馈");
    }

    @OnClick({R.id.back_iv, R.id.submit_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_iv:
                finish();
                break;
            case R.id.submit_btn:
                submit();
                break;
        }
    }

    private void submit() {
        String s = contentEt.getText().toString();
        if(TextUtils.isEmpty(s)){
            showToast("请输入反馈内容");
            return;
        }
        Map<String,String> params= new HashMap<>();
        params.put("feedback",s);
        showProgress();
        NetworkManager.INSTANCE.post(Apis.feedback_add, params, new NetworkManager.OnRequestCallBack() {
            @Override
            public void onOk(String response) {
                hideProgress();showToast("提交成功");
                finish();
            }

            @Override
            public void onError(String errorMessage) {
                hideProgress();
                showToast(errorMessage);
            }
        });

    }
}
